﻿@model ESupervision.ViewModels.TeacherIndexVM
@using Microsoft.AspNet.Identity;

@{
    ViewBag.Title = "TeacherIndex";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<br/>
<p>
    @Html.ActionLink(" Create New", "Create", "Document", null, new { @class = "btn btn-info  glyphicon glyphicon-plus  " })
    @*@Html.ActionLink("Create New", "Create")*@
</p>
<div class="panel panel-success">
    <div class="panel-heading">
        <h3 class="panel-title" id="panel-title">Information Your Attachement File<a class="anchorjs-link" href="#panel-title"><span class="anchorjs-icon"></span></a></h3>
    </div>
    <div class="table-responsive">
        <table class="table table-hover table-responsive ">
            <tr class="info">
                <th>
                    FileName
                </th>
                <th>
                    CreatedTime
                </th>
                <th>
                    FullName
                </th>

                <th>
                    Subject
                </th>
                <th>
                    Body
                </th>
                <th></th>
                
            </tr>

            @foreach (var item in Model.Documents)
            {
                <tr>
                    <td>

                        @Html.DisplayFor(modelItem => item.AttachmentFile.FileName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.CreatedTime)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.CreatedByUser.FullName)
                    </td>

                    <td>
                        @{ var TempSub = "";
                         if (item.Subject.Length > 20)
                         {
                             TempSub = item.Subject.Substring(0, 20) + " ...";
                         }
                         else
                         {
                             TempSub = item.Subject;
                         }
                        }
                        @TempSub
                        @*@Html.DisplayFor(modelItem => item.Subject)*@
                    </td>
                    <td>
                        @{ var TempBoby = "";
                         if (item.Body.Length > 20)
                         {
                             TempBoby = item.Body.Substring(0, 20) + "...";
                         }
                         else
                         {

                             TempBoby = item.Body;
                         }
                        }
                        @TempBoby
                        @*@Html.DisplayFor(modelItem => item.Body)*@
                    </td>
                    <td>
                        @*@Html.ActionLink("Edit", "Edit", "Document", null, new { @class = "btn btn-info btn-sm  glyphicon glyphicon-pencil " })*@
                        @Html.ActionLink("Details", "Details", "Document", new { id = item.DocumentID }, new { @class = "btn btn-success btn-sm  glyphicon glyphicon-pencil " })
                        @{
                if (User.Identity.GetUserId() == item.CreatedByUserId)
                {
                    @Html.ActionLink("Delete", "Delete", "Document", new { id = item.DocumentID }, new { @class = "btn btn-warning btn-sm  glyphicon glyphicon-remove " })
                }
                else
                {
                    @Html.ActionLink("Delete", "Delete", "Document", new { id = item.DocumentID }, new { @class = "btn btn-warning btn-sm  glyphicon glyphicon-pencil hide", @disabled = "disabled" })

                }
                        }
                    </td>
                </tr>
            }

        </table>
    </div>
</div>
<br /><br />
<div class="panel panel-info">
    <div class="panel-heading">
        <h3 class="panel-title" id="panel-title">Information Attachement Document of Your Student<a class="anchorjs-link" href="#panel-title"><span class="anchorjs-icon"></span></a></h3>
    </div>
    <div style="padding:10px;">
        @using (Html.BeginForm())
        {
            <p>
                Find by Student Name: @Html.TextBox("SearchString")
                <button class="btn btn-warning btn-sm" type="submit"><span class="glyphicon glyphicon-search " /> Search</button>
            </p>
        }
    </div>
    <div class="table-responsive">
        <table class="table table-hover  ">
            <tr class="info">
                <th>
                    FullName
                </th>
                <th>
                    Phone
                </th>
                <th>
                    Email
                </th>

                <th>
                    Birthday
                </th>
                <th>
                    EnrolmentDate
                </th>
                <th>
                    Detail Document
                </th>

            </tr>

            @foreach (var item in Model.Students)
            {
                <tr>
                    <td>

                        @Html.DisplayFor(modelItem => item.FullName)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Phone)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Email)
                    </td>
                    <td>

                        @Html.DisplayFor(modelItem => item.Birthday)
                    </td>
                    <td>

                        @Html.DisplayFor(modelItem => item.EnrollmentDate)
                    </td>
                    <td>
                        @Html.ActionLink("Details", "StudentDocuments", "Document", new { id = item.Id }, new { @class = "btn btn-success btn-sm  glyphicon glyphicon-pencil " })

                    </td>
                </tr>
            }

        </table>
    </div>
</div>
